import request from '@/utils/request.js'

export const getUserInfoDetail = () => {
  return request.get('user/getUserInfoDetail')
}

export const uploadAvatar = (file) => {
  return request.post('user/uploadAvatar', file, {
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

export const getUserInfoEdit = () => {
  return request.get('user/getUserInfoEdit')
}

export const updateUserName = (newName) => {
  return request.get('user/updateUserName', {
    params: {
      newName
    }
  })
}
export const getAddressList = () => {
  return request.get('user/getAddressList')
}

export const addAddress = (name, tel, address, detail, isDefault) => {
  return request.post('user/addAddress', {
    name,
    tel,
    address,
    detail,
    isDefault
  })
}

export const getAddress = (addressId) => {
  return request.get('user/getAddress', {
    params: { addressId }
  })
}

export const updateAddress = (name, tel, address, detail, isDefault, id) => {
  return request.post('user/updateAddress', {
    name,
    tel,
    address,
    detail,
    isDefault,
    id
  })
}
export const setPassword = (password) => {
  return request.post('user/setPassword', {
    password
  })
}

export const checkPasswordSet = () => {
  return request.get('user/checkPasswordSet')
}
